<?php

namespace app\api\controller;

use app\api\BaseController;
use app\api\middleware\Auth;
use app\load\loadModel\HaiModel;
use think\Exception;

/**
 * 海外商品
 */
class HaiProduct extends BaseController
{

    /**
     * 免登录方法
     * 控制器中间件 [登录 不需要鉴权]
     * @var array
     */
    protected $middleware = [
        Auth::class => ['except' => []]
    ];

    /**
     * 列表
     * @return void
     */
    public function list(){
        $input = input();
        try {
            $where[] = ['status', '<>', '-1'];
            if (!empty($input['keyword'])){
                $where[] = ['product_sn|product_name','like',"%".$input['keyword']."%"];
            }
            $product_list = HaiModel::Product()->all_list($where, 'product_sn,product_name');
            $this->apiSuccess('请求成功',$product_list);
        }catch (Exception $e){
            $this->apiError($e->getMessage());
        }

    }
}